package Dao

import (
	"fmt"
	"zlxBook/db"
	"zlxBook/model"
)

func GetUserByPhone(phone string) (*model.User, error) {

	user := new(model.User)
	if err := db.DB.Debug().Where("phone=?", phone).First(&user).Error; err != nil {
		fmt.Println(err.Error())
		return nil, err
	}
	fmt.Println("user.phone" + user.Phone)
	return user, nil

}
func CheckPhoneExist(phone string) bool {
	user := new(model.User)
	if err := db.DB.Debug().Where("phone=?", phone).First(&user).Error; err != nil {
		fmt.Println(err.Error())
		return false
	}
	if user.ID != 0 {
		return true
	}
	return false
}
